package com.demo.rabbitmq.producer;

import com.demo.rabbitmq.config.FanoutExchangeEnum;
import com.demo.rabbitmq.config.FanoutQueueEnum;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class FanoutProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void fanout(int i) {
        String exchange = FanoutExchangeEnum.FANOUT_EXCHANGE.getExchangeName();
        String content = String.format("消息=%d，fanout hello world! 当前时间：%s", i, new Date());
        rabbitTemplate.convertAndSend(exchange, "", content);
    }


}
